<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">系统通知信息</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form layui-form-pane" lay-filter="{$lay_table}">
                        <input type="hidden" name="id" value="{:array_get($info,'id')}">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span style="color:#f90c05;">*</span>标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" value="{:array_get($info,'title')}" lay-verify="required"
                                       placeholder="请输入标题" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item" id="form-content">
                            <label class="layui-form-label"><span style="color:#f90c05;">*</span>内容</label>
                            <div class="layui-input-block">
                                <script id="editor" type="text/plain">{:array_get($info,'content')}</script>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span style="color:#f90c05;">*</span>排序</label>
                            <div class="layui-input-block">
                                <input type="text" name="priority" value="{:array_get($info,'priority',255)}"
                                       lay-verify="required|number" placeholder="请输入排序"
                                       autocomplete="off" class="layui-input">
                                <div class="layui-form-mid layui-word-aux">倒序，值越大越靠前</div>
                            </div>
                        </div>
                        <div class="layui-form-item" pane>
                            <label class="layui-form-label"><span style="color:#f90c05;">*</span>状态</label>
                            <div class="layui-input-block">
                                {volist name="status_list" id="v"}
                                <input type="radio" name="status" value="{$key}" title="{$v}" {eq name=":array_get($info,'status',1)" value="$key" }checked{/eq}>
                                {/volist}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="button" lay-submit lay-filter="{$lay_btn}" value="确认提交" class="layui-btn">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/ueditor" /}
<script>
    layui.use(['index', 'form', 'layedit', 'upload'], function () {
        UE.getEditor('editor');
        const admin = layui.admin;
        const layedit = layui.layedit;
        const form = layui.form;
        form.render();

        const content = layedit.build('content', {
            uploadImage: { url: "{:url('upload/image')}", type: 'post' }
        });

        form.verify({
            editcontent: function (value) {
                layedit.sync(content);
            }
        });

        form.on('submit({$lay_btn})', function (obj) {
            const index = parent.layer.getFrameIndex(window.name);
            obj.field.content = UE.getEditor('editor').getContent();
            admin.req({
                url: "{:url('notice/editNotice')}",
                type: 'post',
                data: obj.field,
                done: function (res) {
                    layer.msg("提交成功", {
                        icon: 1
                    });
                    parent.layui.table.reload('lay-notice-index-table'); //重载表格
                    parent.layer.close(index);
                }
            });
        });

    });
</script>
